From 65a0b35bd423f4e9eeec5a854e1645fbe5313d44 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 11 Jul 2012 20:30:14 +0200 Subject: [PATCH] Use local context to get messages and time formatting methods of Language class. Only updated the code in the ImageHistoryList class. Change-Id: I75bbbcb5c93f3c35c347ec8a0156cbb4b7c10142 --- includes/ImagePage.php | 65 ++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/includes/ImagePage.php b/includes/ImagePage.php index c76a5de729..dfeac23759 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -944,18 +944,18 @@ class ImageHistoryList extends ContextSource { * @return string */ public function beginImageHistoryList( $navLinks = '' ) { - return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) ) . "\n" + return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) . "\n" . "
\n" - . $this->getOutput()->parse( wfMsgNoTrans( 'filehist-help' ) ) + . $this->msg( 'filehist-help' )->parseAsBlock() . $navLinks . "\n" . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n" . '' . ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '' : '' ) - . '' . wfMsgHtml( 'filehist-datetime' ) . '' - . ( $this->showThumb ? '' . wfMsgHtml( 'filehist-thumb' ) . '' : '' ) - . '' . wfMsgHtml( 'filehist-dimensions' ) . '' - . '' . wfMsgHtml( 'filehist-user' ) . '' - . '' . wfMsgHtml( 'filehist-comment' ) . '' + . '' . $this->msg( 'filehist-datetime' )->escaped() . '' + . ( $this->showThumb ? '' . $this->msg( 'filehist-thumb' )->escaped() . '' : '' ) + . '' . $this->msg( 'filehist-dimensions' )->escaped() . '' + . '' . $this->msg( 'filehist-user' )->escaped() . '' + . '' . $this->msg( 'filehist-comment' )->escaped() . '' . "\n"; } @@ -997,7 +997,7 @@ class ImageHistoryList extends ContextSource { } $row .= Linker::linkKnown( $this->title, - wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ), + $this->msg( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' )->escaped(), array(), $q ); } @@ -1008,7 +1008,7 @@ class ImageHistoryList extends ContextSource { $row .= '
'; } // If file is top revision or locked from this user, don't link - if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED ) ) { + if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED, $user ) ) { $del = Linker::revDeleteLinkDisabled( $canHide ); } else { list( $ts, ) = explode( '!', $img, 2 ); @@ -1028,16 +1028,16 @@ class ImageHistoryList extends ContextSource { // Reversion link/current indicator $row .= ''; if ( $iscur ) { - $row .= wfMsgHtml( 'filehist-current' ); - } elseif ( $local && $this->title->quickUserCan( 'edit' ) - && $this->title->quickUserCan( 'upload' ) + $row .= $this->msg( 'filehist-current' )->escaped(); + } elseif ( $local && $this->title->quickUserCan( 'edit', $user ) + && $this->title->quickUserCan( 'upload', $user ) ) { if ( $file->isDeleted( File::DELETED_FILE ) ) { - $row .= wfMsgHtml( 'filehist-revert' ); + $row .= $this->msg( 'filehist-revert' )->escaped(); } else { $row .= Linker::linkKnown( $this->title, - wfMsgHtml( 'filehist-revert' ), + $this->msg( 'filehist-revert' )->escaped(), array(), array( 'action' => 'revert', @@ -1054,9 +1054,9 @@ class ImageHistoryList extends ContextSource { $selected = "class='filehistory-selected'"; } $row .= ""; - if ( !$file->userCan( File::DELETED_FILE ) ) { + if ( !$file->userCan( File::DELETED_FILE, $user ) ) { # Don't link to unviewable files - $row .= '' . $lang->timeanddate( $timestamp, true ) . ''; + $row .= '' . $lang->userTimeAndDate( $timestamp, $user ) . ''; } elseif ( $file->isDeleted( File::DELETED_FILE ) ) { if ( $local ) { $this->preventClickjacking(); @@ -1064,7 +1064,7 @@ class ImageHistoryList extends ContextSource { # Make a link to review the image $url = Linker::linkKnown( $revdel, - $lang->timeanddate( $timestamp, true ), + $lang->userTimeAndDate( $timestamp, $user ), array(), array( 'target' => $this->title->getPrefixedText(), @@ -1073,12 +1073,12 @@ class ImageHistoryList extends ContextSource { ) ); } else { - $url = $lang->timeanddate( $timestamp, true ); + $url = $lang->userTimeAndDate( $timestamp, $user ); } $row .= '' . $url . ''; } else { $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img ); - $row .= Xml::element( 'a', array( 'href' => $url ), $lang->timeanddate( $timestamp, true ) ); + $row .= Xml::element( 'a', array( 'href' => $url ), $lang->userTimeAndDate( $timestamp, $user ) ); } $row .= ""; @@ -1090,9 +1090,9 @@ class ImageHistoryList extends ContextSource { // Image dimensions + size $row .= ''; $row .= htmlspecialchars( $file->getDimensionsString() ); - $row .= $this->getContext()->msg( 'word-separator' )->plain(); + $row .= $this->msg( 'word-separator' )->plain(); $row .= ''; - $row .= $this->getContext()->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain(); + $row .= $this->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain(); $row .= ''; $row .= ''; @@ -1100,11 +1100,11 @@ class ImageHistoryList extends ContextSource { $row .= ''; // Hide deleted usernames if ( $file->isDeleted( File::DELETED_USER ) ) { - $row .= '' . wfMsgHtml( 'rev-deleted-user' ) . ''; + $row .= '' . $this->msg( 'rev-deleted-user' )->escaped() . ''; } else { if ( $local ) { $row .= Linker::userLink( $userId, $userText ); - $row .= $this->getContext()->msg( 'word-separator' )->plain(); + $row .= $this->msg( 'word-separator' )->plain(); $row .= ''; $row .= Linker::userToolLinks( $userId, $userText ); $row .= ''; @@ -1116,7 +1116,7 @@ class ImageHistoryList extends ContextSource { // Don't show deleted descriptions if ( $file->isDeleted( File::DELETED_COMMENT ) ) { - $row .= '' . wfMsgHtml( 'rev-deleted-comment' ) . ''; + $row .= '' . $this->msg( 'rev-deleted-comment' )->escaped() . ''; } else { $row .= '' . Linker::formatComment( $description, $this->title ) . ''; } @@ -1134,7 +1134,10 @@ class ImageHistoryList extends ContextSource { */ protected function getThumbForLine( $file ) { $lang = $this->getLanguage(); - if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE ) && !$file->isDeleted( File::DELETED_FILE ) ) { + $user = $this->getUser(); + if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE,$user ) + && !$file->isDeleted( File::DELETED_FILE ) ) + { $params = array( 'width' => '120', 'height' => '120', @@ -1143,20 +1146,20 @@ class ImageHistoryList extends ContextSource { $thumbnail = $file->transform( $params ); $options = array( - 'alt' => wfMsg( 'filehist-thumbtext', - $lang->timeanddate( $timestamp, true ), - $lang->date( $timestamp, true ), - $lang->time( $timestamp, true ) ), + 'alt' => $this->msg( 'filehist-thumbtext', + $lang->userTimeAndDate( $timestamp, $user ), + $lang->userDate( $timestamp, $user ), + $lang->userTime( $timestamp, $user ) )->text(), 'file-link' => true, ); if ( !$thumbnail ) { - return wfMsgHtml( 'filehist-nothumb' ); + return $this->msg( 'filehist-nothumb' )->escaped(); } return $thumbnail->toHtml( $options ); } else { - return wfMsgHtml( 'filehist-nothumb' ); + return $this->msg( 'filehist-nothumb' )->escaped(); } } -- 2.20.1